package org.example.controller;

import org.example.pojo.Tags;
import org.example.service.TagsService;
import org.example.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/tags")
public class TagsController {
    @Autowired
    private TagsService tagsService;
    @GetMapping
    public Result tagsList(Integer userId, String tagName) {
            Tags tag = new Tags();
            tag.setUserId(userId);
            tag.setTagName(tagName);
            List<Tags> tags = tagsService.tagsList(tag);
            return Result.success(tags);
    }
    @PostMapping
    public Result addTag(@RequestBody Tags tags) {
            tagsService.addTag(tags);
            return Result.success();
    }
    @DeleteMapping
    public Result deleteTag(@RequestBody Tags tags) {
            return tagsService.delTag(tags);
    }
    @PutMapping
    public Result editTag(@RequestBody Tags tags) {
            tagsService.editTag(tags);
            return Result.success();
    }
}
